#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User as DjangoUser
from django.utils.translation import ugettext_lazy as _
from django.conf import settings

User = DjangoUser

class Product(models.Model):
    number = models.IntegerField(u'品号')
    name = models.CharField(u'品名', max_length=180)
    model_name = models.CharField(u'型号', max_length=180)
    category = models.CharField(u'分类', max_length=180)
    unit = models.CharField(u'单位', max_length=180)
    location = models.CharField(u'库位', max_length=180)
    count = models.IntegerField(u'库存')
    remark = models.CharField(u'备注', max_length=180)

    def __unicode__(self):
        return '%s' % self.name

    class Meta:
        verbose_name = _('Product')
        verbose_name_plural = _('Products')


class OperationLog(models.Model):
    '''操作明细'''
    operation_datetime = models.DateTimeField(u'操作时间', auto_now_add=True)
    product = models.ForeignKey('Product')
    operation_type = models.CharField(u'入库/出库', max_length=180)
    count = models.IntegerField(u'数量')
    remain = models.IntegerField(u'结余')
    user = models.CharField(u'操作员', max_length=180)
    remark = models.CharField(u'备注', max_length=180)


    def __unicode__(self):
        return self.operation_type
    class Meta:
        verbose_name = _('OperationLog')
        verbose_name_plural = _('OperationLogs')


